package com.zkk.web;

import com.alibaba.fastjson.JSON;
import com.zkk.pojo.Account;
import com.zkk.pojo.User;
import com.zkk.service.AccountService;
import com.zkk.service.UserService;
import com.zkk.service.impl.AccountServiceImpl;
import com.zkk.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/setPwd")
public class setPwdServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;utf-8");
        resp.setCharacterEncoding("utf-8");
        //手机号问题未解决，如何在开户后得到手机号是个问题
        String telephone = req.getParameter("telephone");

        String payment_pwd = req.getParameter("payment_pwd");
        AccountService accountService = new AccountServiceImpl();
        Account account = new Account();
        account.setTelephone(telephone);
        account.setPayment_pwd(payment_pwd);
        int i = accountService.setPwd(account);
        System.out.println(i);
        if(i==1){
            resp.sendRedirect("/pages/card/card_binding.jsp");
        }else{
            resp.getWriter().write("账号不存在，设置密码失败");
        }


    }
}
